package cn.tedu.yl.professional.controller;

import cn.tedu.yl.base.response.JsonResult;
import cn.tedu.yl.base.response.PageData;
import cn.tedu.yl.professional.pojo.dto.ProfessionalDelParam;
import cn.tedu.yl.professional.pojo.dto.ProfessionalQuery;
import cn.tedu.yl.professional.pojo.dto.ProfessionalSaveParam;
import cn.tedu.yl.professional.pojo.vo.ProfessionalVO;
import cn.tedu.yl.professional.service.ProfessionalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "职称管理")
@RestController
@RequestMapping("/v1/professional")
@Slf4j
public class ProfessionalController {
    @Autowired
     private ProfessionalService professionalService;

    @ApiOperation(value = "查看列表数据")
    @GetMapping("list")
    public JsonResult list(@Validated ProfessionalQuery professionalQuery){
        PageData pageData = professionalService.selectList(professionalQuery);
        return JsonResult.ok(pageData);
    }

    @ApiOperation(value = "查询职称详情")
    @GetMapping("detail/{id}")
    public JsonResult selectDetailById(@PathVariable("id") Integer id){
        ProfessionalVO professionalVO = professionalService.selectDetailById(id);
        return JsonResult.ok(professionalVO);
    }

    @ApiOperation(value = "保存数据")
    @PostMapping("save")
    public JsonResult save(@Validated @RequestBody ProfessionalSaveParam professionalSaveParam){
        professionalService.save(professionalSaveParam);
        return JsonResult.ok();
    }

    @ApiOperation(value = "批量删除数据")
    @PostMapping("delete")
    public JsonResult delete(@RequestBody ProfessionalDelParam pofessionalDelParam){
        professionalService.delete(pofessionalDelParam);
        return JsonResult.ok();
    }

}
































